/* 
     Purpose: This file uses the following dictionary 
              (alongside the codebook) to bring in raw data.
	
	 Creates: ocg1962.dta
*/

clear
cd "$Mydirectory1/1_DataSources/CPS_1962_1973/"

**********************************************************

infix ///
	age_ccm 27-29 ///
	race_ccm 30 ///
	marital_status 31 ///
	marital_ccm 48 ///
	R_num_sisters 65-66 ///
	R_num_brothers 69-70 ///
	R_wholivedw_age16 186 ///
	R_numkids_ever 98-99 ///
	schl_ccm 166-167 ///
	houserel_ccm 32-33 ///
	income_total_ccm 200-201 ///
	income_1961_ccm 202-203 /// 
	age_ccw 80-82 ///
	race_ccw 238-239 ///
	schl_ccw 170-171 ///
	schl_dad_ocg 168-169 ///
	ses_dad_ocg 143-145 ///
	ses_wifedad_ocg 155-157 ///
	ses_firstjob_ocg 131-133 ///
	ses_resp_ocg 119-121 ///
	weight 50-61 ///
	region 25 /// 
	dad_occ1960 134-137 /// 
	dad_clsswrk 142 /// 
	birthplace 35-37 /// 
	birthplace_father 39-41 /// 
	birthplace_mother 42-44 /// 
	migration 184-185 /// 
	employment 34 /// 
	occupationR 110-113 /// 
	son_clsswrk 118 /// 
	using "./RawData/06162-0001-Data.txt" //download from ICPSR website. Search ICPSR 6162. Name is the same.

**********************************************************

* Add ID variable
gen id = _n

* Add sex variable
gen sex_ccm = 1
gen sex_ccw = 2

* Recode sibling variables
replace R_num_sisters =. if R_num_sisters==10
replace R_num_brothers =. if R_num_brothers==10

* Recode wife variables
replace age_ccw = . if age_ccw==0
replace race_ccw = . if race_ccw==14
replace schl_ccw = . if schl_ccw==0

* Recode wife race variable
replace race_ccw = 1 if race_ccw<=8
replace race_ccw = 2 if race_ccw>=9

* Recode other missing variables
replace schl_dad_ocg = . if schl_dad_ocg==9
replace ses_dad_ocg = . if ses_dad_ocg==99
replace ses_wifedad_ocg = . if ses_wifedad_ocg==99
replace ses_firstjob_ocg = . if ses_firstjob_ocg==99
replace ses_resp_ocg = . if ses_resp_ocg==99

replace income_total_ccm = . if income_total_ccm>=18
replace income_1961_ccm = . if income_1961_ccm>=9 

replace R_wholivedw_age16 =. if R_wholivedw_age16==5 //NA
tab R_wholivedw_age16,m 

**********************************************************
	
/// Characteristics of Civilan Males (CCM) ///
label variable id "ID number"
label variable age_ccm  "Age, CCM"
label variable race_ccm "Race, CCM"
label variable sex_ccm "Sex, CCM"
label variable schl_ccm "Educational attainment, CCM"
label variable houserel_ccm "Household relationship, CCM"
label variable income_total_ccm "Total Income, CCM"
label variable income_1961_ccm "Husband's Income in 1961, CCM"

/// Characteristics of the Wife (CCW) ///
label variable age_ccw "Age, CCW"
label variable race_ccw "Race, CCW"
label variable sex_ccw "Sex, CCW"
label variable schl_ccw "Educational attainment, CCW"

/// Occupational Changes in a Generation (OCG) ///
label variable schl_dad_ocg "Highest grade completed by father, OCG"
label variable ses_dad_ocg "Socioeconomic Status Score (father), OCG"
label variable ses_wifedad_ocg "Socioeconomic Status Score (father), OCG"
label variable ses_firstjob_ocg "Socioeconomic Status Score (father), OCG"
label variable ses_resp_ocg "Socioeconomic Status Score (father), OCG"

/// Weights ///
label variable weight "Weight"

/// Variables ///
label variable region "Region"
label variable dad_occ1960 "Father's occupation, 1960 code"
label variable occupationR "Respondent's occupation, 1960 code"
label variable dad_clsswrk "Father class of worker"
label variable birthplace "Respondent's birthplace"
label variable birthplace_father "Father's birthplace"
label variable birthplace_mother "Mother's birthplace"
label var migration "Migration variable"
label var employment "Employment status"

**********************************************************

label data "OCG 1962"

#delimit ;
label define race1     0.00 "White" 1.00 "Black"
                       2.00 "Other";
label define race2     1.00 "White" 2.00 "Non-white";					   
label define sex       1.00 "Male" 2.00 "Female";
label define school    0.00 "None" 1.00 "Elementary 1-4"
                       2.00 "Elementary 5-7" 3.00 "Elementary 8"
                       4.00 "High School 1-3" 5.00 "High School 4"
                       6.00 "college 1-3" 7.00 "College 4"
                       8.00 "College 5+";
label define income    0.00 "None"
                       1.00 "Less, $1-499" 
                       2.00 "$500-999" 
					   3.00 "$1,000-1,499"
                       4.00 "$1,500-1,999" 
					   5.00 "$2,000-2,499"
                       6.00 "$2,500-2,999" 
					   7.00 "$3,000-3,499"
                       8.00 "$3,500-3,999"
                       9.00 "$4,000-4,499"
                       10.00 "$4,500-4,999"
                       11.00 "$5,000-5,999"
					   12.00 "$6,000-6,999"
					   13.00 "$7,000-7,999"
                       14.00 "$8,000-9,999"
                       15.00 "$10,000-14,999" 
                       16.00 "$15,000-24,999"
                       17.00 "$25,000 or more";
label define income2   0.00 "None"
					   1.00 "$1-1,999 or less"
                       2.00 "$2,000-2,999" 
					   3.00 "$3,000-3,999"
                       4.00 "$4,000-4,999" 
					   5.00 "$5,000-6,999"
                       6.00 "$7,000-9,999" 
                       7.00 "$10,000-14,999"
                       8.00 "$15,000 or more";
label define hhold     0.00 "Primary family head, MSP"
					   1.00 "Primary family head, other"
                       2.00 "Subfamily head, MSP" 
					   3.00 "Subfamily head, other"
                       4.00 "Relative of primary family head (not in subfamily)" 
					   5.00 "Seconday family head, MSP"
                       6.00 "Secondary family head, other" 
                       7.00 "Relative of seconday family head"
                       8.00 "Primary individual"
					   9.00 "Secondary individual";
label define clss	   0 "Private" 1 "Govt employee" 2 "Self-employed"
					   3 "Without pay";
label define empstatus 0 "Armed forces" 1 "NILF" 2 "Unemployed, new worker" 
					   3 "Unemployed, experienced worker" 4 "Employed";
					   
#delimit cr

label values race_ccm race1
label values race_ccw race2
label values sex_ccm sex
label values sex_ccw sex
label values schl_ccm school
label values schl_ccw school
label values schl_dad_ocg school
label values income_total_ccm income
label values income_1961_ccm income2
label values houserel_ccm hhold
label values dad_clsswrk clss
label values employment empstatus

********************************************************************


save "./output/ocg1962.dta", replace
